VERSION 	=1.00
CC			=gcc
DEBUG 		=-DUSE_DEBUG
CFLAGS		=-Wall
FILES 		:=$(wildcard ./src/*.c ../utils/*.c)
SOURCES	 	+=$(filter-out ../utils/map.c ./src/client.c,$(FILES))
INCLUDES  	=-I./include -I../utils
LIB_NAMES 	=-lpthread -lm
LIB_PATH 	=-L./lib
OBJ			=$(patsubst %.c, %.o, $(SOURCES))
TARGET		=server


#links
$(TARGET):$(OBJ)
	@mkdir -p output
	$(CC) $(OBJ) $(LIB_PATH) $(LIB_NAMES) -o output/$(TARGET)$(VERSION)
	# @rm -rf $(OBJ)
	
#compile
%.o: %.c
	$(CC) $(INCLUDES) $(DEBUG) -c $(CFLAGS) $< -o $@

.PHONY:clean echoinfos
clean:
	@echo "Remove linked and compiled files......"
	rm -rf $(OBJ) $(TARGET) output 


echoinfos:
	$(info VERSION=$(VERSION))
	$(info CC=$(CC))
	$(info CFLAGS=$(CFLAGS))
	$(info SOURCES=$(SOURCES))
	$(info INCLUDES=$(INCLUDES))
	$(info LIB_NAMES=$(LIB_NAMES))
	$(info LIB_PATH=$(LIB_PATH))
	$(info OBJ=$(OBJ))
	$(info TARGET=$(TARGET))
